import { validateArr, validateNormal } from '../../../../../utils/jk/validator';

export default {
	data() {
		return {
			technologyOrderInfo: {
				'batchCode': '',
				'code': '',
				'dailyYield': 0,
				'efficiencyPercent': 0,
				'fixedLength': 0,
				'gramWeight': 0,
				'id': null,
				'machineModelCode': '',
				'machineModelId': 0,
				'machineModelName': '',
				'meters': 0,
				'moistureRegain': 0,
				'numbers': 0,
				'processCode': '',
				'processId': 0,
				'processName': '',
				'productCode': '',
				'productId': 0,
				'productModels': '',
				'productName': '',
				'specDate': '',
				'specEmpId': 0,
				'specEmpName': '',
				'specSheetParamList': [],
				'spindleNum': 0
			},
			ruleForm: {
				'code': '',
				'id': null,
				'belongDate': '',
				'auditState': 0,
				'paperTubeList': [],
				'ifTest': false,
				'productOrderId': null,
				'productOrderBatchItem': {},
				'productOrderCode': null,
				'actualityProductionQty': '',
				'spunYarnBomItemList': [],
				'rovingColors': [],
				'spunYarnBomCode': '',
				'spunYarnBomId': null,
				'batchId': null,
				'batchCode': '',
				'completionQty': null,
				'dailyYield': null,
				'finishState': null,
				'gramWeight': null,
				'machineQty': null,
				'meters': null,
				'productionQty': null,
				'planDailyQty': null,
				'planFinishDate': '',
				'planMachineQty': null,
				'planStartDate': '',
				'prdNoticeMachineList': [],
				'processCode': '',
				'processId': null,
				'processName': '',
				'productCode': '',
				'productId': null,
				'productModels': '',
				'productName': '',
				'productionDailyQty': null,
				'machineParams': {
					'remark': '',
					'gangShiQuan': '',
					'geJuKuai': '',
					'shangCheDateTime': ''
				},
				'salesCode': '',
				'specSheetCode': '',
				'specSheetId': null,
				'startState': null,
				'unitCode': '',
				'unitId': null,
				'unitName': '',
				'workshopId': null,
				'workshopName': '',
				'productOrder': {}
			},
			rules: {
				paperTubeList: [{ required: true, validator: validateArr, trigger: 'change' }],
				gramWeight: [{ required: true, trigger: 'change' }],
				tenPrice: [{ required: true, trigger: 'change' }],
				productOrderId: [{ required: true, trigger: 'change' }],
				batchId: [{ required: true, trigger: 'change' }],
				productId: [{ required: true, trigger: 'change' }],
				rovingColors: [{ required: true, trigger: 'change' }],
				spunYarnColors: [{ required: true, trigger: 'change' }],
				dailyYield: [{ required: true, trigger: 'change' }],
				planStartDate: [{ required: true, trigger: 'change' }],
				planFinishDate: [{ required: true, trigger: 'change' }],
				productionDailyQty: [{ required: true, trigger: 'change' }],
				productionQty: [{ required: true, trigger: 'change' }],
				workshopId: [{ required: true, trigger: 'change' }]
			}
		};
	},
	methods: {
		clearFormItemVal(type = 'workshop') {
			if (type === 'workshop') {
				this.$set(this.ruleForm, 'productOrderId', null);
				this.$set(this.ruleForm, 'productOrderCode', null);
				this.$set(this.ruleForm, 'productId', null);
				this.$set(this.ruleForm, 'productCode', '');
				this.$set(this.ruleForm, 'productName', '');
				this.$set(this.ruleForm, 'batchId', null);
				this.$set(this.ruleForm, 'batchCode', '');
				this.$set(this.ruleForm, 'spunYarnList', []);
				this.$set(this.ruleForm, 'specSheetId', null);
				this.$set(this.ruleForm, 'specSheetCode', '');
				this.$set(this.ruleForm, 'gramWeight', null);
				this.$set(this.ruleForm, 'meters', null);
				this.$set(this.ruleForm, 'productionQty', null);
				this.$set(this.ruleForm, 'planStartDate', null);
				this.$set(this.ruleForm, 'planFinishDate', null);
				this.$set(this.ruleForm, 'productionDailyQty', null);
				this.$set(this.ruleForm, 'actualityProductionQty', null);
				this.$set(this.ruleForm, 'actualityProductionQty', null);
				this.$set(this.ruleForm.productOrder, 'allocatedQty', null);
				this.$set(this.ruleForm.productOrder, 'dailySupplyQty', null);
				this.$set(this.ruleForm.productOrder, 'dailyYield', null);
				this.$set(this.ruleForm.productOrder, 'plannerQty', null);
				this.$set(this.ruleForm, 'spunYarnBomItemList', []);
				this.$set(this.ruleForm, 'prdNoticeMachineList', []);
			} else if (type === 'product') {
				this.$set(this.ruleForm, 'spunYarnList', []);
				this.$set(this.ruleForm, 'specSheetId', null);
				this.$set(this.ruleForm, 'specSheetCode', '');
				this.$set(this.ruleForm, 'gramWeight', null);
				this.$set(this.ruleForm, 'meters', null);
				this.$set(this.ruleForm, 'productionQty', null);
				this.$set(this.ruleForm, 'planStartDate', null);
				this.$set(this.ruleForm, 'planFinishDate', null);
				this.$set(this.ruleForm, 'productionDailyQty', null);
				this.$set(this.ruleForm, 'actualityProductionQty', null);
				this.$set(this.ruleForm, 'actualityProductionQty', null);
				this.$set(this.ruleForm.productOrder, 'allocatedQty', null);
				this.$set(this.ruleForm.productOrder, 'dailySupplyQty', null);
				this.$set(this.ruleForm.productOrder, 'dailyYield', null);
				this.$set(this.ruleForm.productOrder, 'plannerQty', null);
				this.$set(this.ruleForm, 'spunYarnBomItemList', []);
				this.$set(this.ruleForm, 'prdNoticeMachineList', []);
			} else if (type === 'batchCode') {
				this.$set(this.ruleForm, 'spunYarnList', []);
				this.$set(this.ruleForm, 'specSheetId', null);
				this.$set(this.ruleForm, 'specSheetCode', '');
				this.$set(this.ruleForm, 'gramWeight', null);
				this.$set(this.ruleForm, 'meters', null);
				this.$set(this.ruleForm, 'productionQty', null);
				this.$set(this.ruleForm, 'planStartDate', null);
				this.$set(this.ruleForm, 'planFinishDate', null);
				this.$set(this.ruleForm, 'productionDailyQty', null);
				this.$set(this.ruleForm, 'actualityProductionQty', null);
				this.$set(this.ruleForm, 'actualityProductionQty', null);
				this.$set(this.ruleForm.productOrder, 'allocatedQty', null);
				this.$set(this.ruleForm.productOrder, 'dailySupplyQty', null);
				this.$set(this.ruleForm.productOrder, 'dailyYield', null);
				this.$set(this.ruleForm.productOrder, 'order', { batchCode: '', planFinishDate: '', planStartDate: '', productModels: '', unitName: '', code: '', dailySupplyQty: null, customerName: '' });
				this.$set(this.ruleForm.productOrder, 'plannerQty', null);
				this.$set(this.ruleForm, 'spunYarnBomItemList', []);
				this.$set(this.ruleForm, 'prdNoticeMachineList', []);
			} else if (type === 'afterPlanOrder') {
				this.$set(this.ruleForm, 'spunYarnList', []);
				this.$set(this.ruleForm, 'specSheetId', null);
				this.$set(this.ruleForm, 'specSheetCode', '');
				this.$set(this.ruleForm, 'gramWeight', null);
				this.$set(this.ruleForm, 'meters', null);
				this.$set(this.ruleForm, 'productionQty', null);
				this.$set(this.ruleForm, 'planStartDate', null);
				this.$set(this.ruleForm, 'planFinishDate', null);
				this.$set(this.ruleForm, 'productionDailyQty', null);
				this.$set(this.ruleForm, 'actualityProductionQty', null);
				this.$set(this.ruleForm, 'actualityProductionQty', null);
				this.$set(this.ruleForm.productOrder, 'allocatedQty', null);
				this.$set(this.ruleForm.productOrder, 'dailySupplyQty', null);
				this.$set(this.ruleForm.productOrder, 'dailyYield', null);
				this.$set(this.ruleForm.productOrder, 'plannerQty', null);
				this.$set(this.ruleForm, 'spunYarnBomItemList', []);
				this.$set(this.ruleForm, 'prdNoticeMachineList', []);
			} else if (type === 'technology') {
				this.$set(this.ruleForm, 'spunYarnList', []);
				this.$set(this.ruleForm, 'gramWeight', null);
				this.$set(this.ruleForm, 'meters', null);
				this.$set(this.ruleForm, 'actualityProductionQty', null);
				this.$set(this.ruleForm, 'actualityProductionQty', null);
				// this.$set(this.ruleForm, 'prdNoticeMachineList', []);
			}
		}
	}
};
